namespace Aob.Lite.Dsl

import System

import Boo.Lang.Compiler
import Boo.Lang.Compiler.Ast

class PointcutMacro(AbstractAstMacro):
"""Description of PointcutMacro"""
	
	override def Expand(macro as MacroStatement):
		assert 1 == macro.Arguments.Count
		assert macro.Arguments[0] isa MemberReferenceExpression

		finder = BlockFinder(Annotations.Advice)
		macro.Block.Accept(finder)
		assert len(finder.Blocks) <= 1, "A pointcut cant have more then one advice associated"

		block = macro.Block.CloneNode()
		block.Annotate(Annotations.Pointcut, PointcutInfo(macro, finder.Blocks))
		return block

class PointcutInfo:
	
	[getter(Macro)]
	_macro as MacroStatement
	
	[getter(AdviceBlocks)]
	_blocks as (Block)
	
	def constructor(macro as MacroStatement, blocks as (Block)):
		_macro = macro
		_blocks = blocks
		
	override def ToString():
		return "Pointcut to: ${_macro.Arguments[0]} - ${len(_blocks)} advice"

